const db = wx.cloud.database();
const E_sportsCircle = db.collection('campus_E-sportsCircle_userinfo');
const E_sportsCircle_Category1 = db.collection('campus_E-sportsCircle_Category-1');
const E_sportsCircle_Category2 = db.collection('campus_E-sportsCircle_Category-2');

function getOpenid(parms) {
  return new Promise((resolve, reject) => {
    E_sportsCircle.where({
      _openid: parms
    }).get().then(res => {
      resolve(res);
    }).catch(err => {
      reject(err);
    })
  })
};


function category1(parms) {
  return new Promise((resolve, reject) => {
    E_sportsCircle_Category1.where({
      _openid: parms
    }).get().then(res => {
      resolve(res);
    }).catch(err => {
      reject(err);
    })
  })
};
function category1_phone(parms) {
  return new Promise((resolve, reject) => {
    E_sportsCircle_Category1.where({
      user_phone: parms
    }).get().then(res => {
      resolve(res);
    }).catch(err => {
      reject(err);
    })
  })
};
function category1_name(parms) {
  return new Promise((resolve, reject) => {
    E_sportsCircle_Category1.where({
      user_Name: parms
    }).get().then(res => {
      resolve(res);
    }).catch(err => {
      reject(err);
    })
  })
};


function category2(parms) {
  return new Promise((resolve, reject) => {
    E_sportsCircle_Category2.where({
      _openid: parms
    }).get().then(res => {
      resolve(res);
    }).catch(err => {
      reject(err);
    })
  })
}

module.exports = {
  getOpenid,
  category1,
  category1_phone,
  category1_name,
  category2
}